﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace frag_boardgame
{
    [DataContract]
    public class GameConfiguration
    {

        int nPlayers;
        int rows;    
        int cols;
        string boardName; //uses for preset boards

        [DataMember]
        public string BoardName
        {
            get { return boardName; }
            set { boardName = value; }
        }

        [DataMember]
        public int NumberOfPlayers
        {
            get { return nPlayers; }
            set { nPlayers = value; }
        }
 
        [DataMember]
        public int Rows
        {
            get { return rows; }
            set { rows = value; }
        }

        [DataMember]
        public int Cols
        {
            get { return cols; }
            set { cols = value; }
        }

        

        public GameConfiguration()
        {
        }

        public GameConfiguration(int rows, int cols, int nPlayers)
        {
            this.rows = rows;
            this.cols = cols;
            this.nPlayers = nPlayers;
        }
       
        public GameConfiguration(string boardName, int nPlayers)
        {
            this.nPlayers = nPlayers;
            this.BoardName = boardName;
        }

        // override object.Equals
        public override bool Equals(object obj)
        {
            GameConfiguration other = obj as GameConfiguration;
            if (other == null) return false;

            return (nPlayers.Equals(other.nPlayers) &&
                rows.Equals(other.rows) &&
                cols.Equals(other.cols));
        }

        // override object.GetHashCode
        public override int GetHashCode()
        {
            return nPlayers.GetHashCode() ^ rows.GetHashCode() ^ cols.GetHashCode();
        }


    }
}
